package org.sction.manager.file;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.io.IOUtils;

public class UploadFileProperties {
	private static final UploadFileProperties instance = new UploadFileProperties();

	private UploadFileProperties() {
	}

	Properties props = new Properties();
	{
		InputStream in = null;
		try {
			in = UploadFileProperties.class.getClassLoader()
					.getResourceAsStream("file.properties");
			props.load(in);
		} catch (IOException e) {
			throw new RuntimeException(e.getMessage(), e.getCause());
		} finally {
			if (in != null) {
				IOUtils.closeQuietly(in);
			}
		}
	}

	public static UploadFileProperties getInstance() {
		return instance;
	}

	public String getValue(String key) {
		return props.getProperty(key);
	}

	public String getFoloderPath() {
		return getValue("file_path");
	}

	public int getMemorySize() {
		return Integer.parseInt(getValue("max_memory_size"));
	}

	public int getMaxRequestSize() {
		return Integer.parseInt(getValue("max_request_size"));
	}

	public int getMaxFileSize() {
		return Integer.parseInt(getValue("max_file_size"));
	}
}
